Object

DatabaseField Class

Used to access the values of fields in a record in a database table.

Properties

BooleanValue

MacPICTValue

DateValue

Name

DoubleValue

StringValue

IntegerValue

Value

JPEGValue

 

Notes


Assignments to the DateValue property store the time as well as the date, as with DatabaseRecords. When getting a value, the resulting Date object may contain a time as well as a date. For fields of type Date, the time will be 00:00:00 (midnight); and for fields of type Time, the date will be January 1, 0001. Fields of type TimeStamp contain valid data for both the date and time.

Boolean fields are strict about what they expect when using the BooleanValue function. Previously, "0" and "False" were treated as False and anything else was treated as True. Now, "0" and "False" are treated as False and "1" and "True" are treated as True. The behavior of any other values is undefined when retrieved using BooleanValue.

The StringValue property, on the other hand, should be able to retrieve the original data if it can't be identified as a Boolean. If the REAL SQL Database can identify the value as a boolean, however, then "False" will always return False and "True" will always return True, regardless of how those values are stored in the database.

The conversion operator, Operator_Convert, has been added to StringValue, BooleanValue, DateValue, IntegerValue, and DoubleValue.


Examples

The following example uses the Value property to set the values of fields of different data types.

Dim MyDB as Database
Dim rs as RecordSet
rs = MyDB.SQLSelect("select * from mytable")
rs.Edit
rs.field("MyName").value = Nil // NULL this field,
//does not work for all database plugins
rs.field("MyID").value = 23
rs.field("MyText").value = "Test"
rs.update
MyDB.Commit

The following method populates a ListBox with a RecordSet. It uses the Name and StringValue properties to obtain the fieldnames and values:

Sub populateCursor(d as RecordSet)
  Dim i as Integer
  Dim v as String

  ListBox1.deleteAllRows
  ListBox1.columncount = d.fieldcount
  ListBox1.addrow d.IdxField(1).Name
  ListBox1.cellBold(ListBox1.lastIndex, 0) = true
 for i = 2 to d.fieldcount
   ListBox1.cell(ListBox1.lastIndex,i-1) =d.IdxField(i).name
   ListBox.cellBold( ListBox.lastIndex, i-1) = true
 next
 While not d.eof
  v = d.IdxField(1).StringValue
   ListBox1.addrow v
   For i = 2 to d.fieldcount
     ListBox.cell( ListBox.lastIndex,i-1)=d.IdxField(i).StringValue
   next
  d.MoveNext
 wend

See Also

Database, DatabaseRecord, RecordSet classes.